from PyQt5 import QtWidgets
from PyQt5 import QtCore
from PyQt5 import QtGui

import sys

class QFontDialogTest(QtWidgets.QWidget):
    def __init__(self, parent=None):
        super(QFontDialogTest, self).__init__(parent)

        self.setWindowTitle("QFontDialogTest例子")
        self.resize(400, 200)
        self.font_btn = QtWidgets.QPushButton(self)
        self.font_btn.setText("选择字体")
        self.font_btn.clicked.connect(self.get_font)

        self.font_label = QtWidgets.QLabel(self)
        self.font_label.setText("Hello, 测试字体")

        _layout = QtWidgets.QVBoxLayout()
        _layout.addWidget(self.font_btn)
        _layout.addWidget(self.font_label)

        self.setLayout(_layout)

    def get_font(self):
        font, ok = QtWidgets.QFontDialog.getFont()
        if ok:
            self.font_label.setFont(font)
            print(font.family())
            print(font.pointSize())


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    QtWidgets.QApplication.setStyle("Fusion")
    win = QFontDialogTest()
    win.show()
    sys.exit(app.exec_())